package _99练习;

import java.io.File;

public class FileControl {
	public static void CreateDir(String src)
	{
		File f = new File(src);
		if(f.exists())
		{
			System.out.println("文件大小"+f.length());
		}
		else
		{
			System.out.println(f.mkdirs());
		}
	}
	
	public static void CreateFileOrDir(String src)
	{
		File f = new File(src);
		if(f.isDirectory())
		{
			File[] fs = f.listFiles();
			int sum=0;
			for(File ff:fs)
			{
				sum+=ff.length();
			}
			System.out.println(src+"文件夹下所有文件大小之和:"+sum);
		}
		else
		{
			System.out.println("文件大小:"+f.length());
		}
	}
	
	public static void DeleteDir(String src)
	{
		File f = new File(src);
		if(f.listFiles().length==0)
		{
			f.delete();
			System.out.println("删除成功");
		}
		else
		{
			System.out.println("需要先将文件删除才能删除文件夹");
		}
	}
}
